library(tidyr)
install.packages("tidyr")
version
library(dplyr)
library(tidyr)
library(ggplot2)
# PREPROCESS --------------------------------------------------------------
rawdata = read.csv(file="f706164-8.csv", head=T)
# select and rename relevant columns
mydata2 = select(rawdata, 13:18, ncol(rawdata))
colnames(mydata2) = c("Flu","Uniform","Candidate","Stephen",  "Excursion",	"Marconi","CELL")
# recode so that 0 is majority and 1 is plurality
mydata2[mydata2=="2"] = 0
mydata2[mydata2=="1"] = 1
# filter out the 3-person committees, and drop obsolete level
mydata2 = filter(mydata2, CELL!="C02")
mydata2$CELL = droplevels(mydata2$CELL)
# create Ratio factor
mydata2 = mutate(mydata2, Ratio = factor(substr(mydata2$CELL,3,3), labels=c("6 to 4", "9 to 1")))
# create Treatment Factor
mydata2 = mutate(mydata2, Treatment = factor(substr(mydata2$CELL,2,2), labels = c("Baseline","Defense","Reminder","Responsibility")))
# delete CELL column, replace with ID column
mydata2$CELL = NULL
mydata2$ID = paste("subj",1:nrow(mydata2), sep="")
# create the Negative and Neutral columns
mydata2 = mutate(mydata2, Negative = Stephen + Marconi + Uniform, Neutral =  Flu + Candidate + Excursion)
# reshape into long form
mydata3 = mydata2 %>% select(7:11) %>% gather(Consequence, Plurality, Negative:Neutral)
install.packages("dplyr")
install.packages("ggplot2")
install.packages("xtable")
library(dplyr)
library(tidyr)
library(ggplot2)
version
?z.test
??z.test
setwd("/Users/edmondawad/Dropbox (MIT)/Gov2001/Project/Languages dataset/Books")
setwd("/Users/edmondawad/Dropbox (MIT)/Gov2001/Project/")
setwd("/Users/edmondawad/Dropbox (MIT)/Gov2001/Project/Languages dataset/Books/")
setwd("/Users/edmondawad/Dropbox (MIT)/Gov2001/Project/Languages datasets/Books/")
mydata <- read.tsv(file="dataset_stats_books.tsv",head=T,sep=",")
mydata <- read.csv(file="dataset_stats_books.tsv",head=T,sep=",")
View(mydata)
mydata <- read.csv(file="dataset_stats_books.tsv",head=T,sep="\t")
setwd("/Users/edmondawad/Dropbox (MIT)/Gov2001/Project/Languages datasets/Books/")
mydata <- read.csv(file="dataset_stats_books.tsv",head=T,sep="\t")
unesco.langinfo <- read.csv(file="unesco_langinfo_20120722_iso639-3.txt",head=T,sep="\t")
stats.books <- read.csv(file="dataset_stats_books.tsv",head=T,sep="\t")
View(unesco.langinfo)
unesco.langlang <- read.csv(file="unesco_langlang_20120722_iso639-3.txt",head=T,sep="\t")
View(unesco.langlang)
books.nodes <- read.csv(file="books_nodes.tsv",head=T,sep="\t")
View(books.nodes)
books.edges <- read.csv(file="books_edges.tsv",head=T,sep="\t")
View(books.edges)
View(stats.books)
pairs(stats.books)
View(stats.books)
View(books.nodes)
